<template>
  <router-view/>
</template>

<script>
import {refreshStatus,showStatusTip,clearStatus} from "@/utils/loginStatus"
export default {
   mounted(){
     //全局刷新用户状态
     window.addEventListener("load",async ()=> {
        console.log("刷新");
        let tag = await refreshStatus()
        let name  = this.$route.name;
        if(!tag){
          if(name === 'forget' || name === 'register'|| name === 'login') {
            //路由转跳导致刷新至这三个页面清除状态
            clearStatus()
            return
          }
          showStatusTip(()=>{this.$router.push("/login")},"请前往注册！")
        }
     })
   }
}
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
